<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.FileOutputStream" %>
<%@ page import="java.util.Scanner" %>
<%@ page import="java.io.FileInputStream" %><%--
  Created by IntelliJ IDEA.
  User: 迷路的麋鹿
  Date: 2018/4/12
  Time: 18:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
    String name=request.getParameter("name");
    String content=request.getParameter("content");
    String path=application.getRealPath("");
    OutputStream outputStream=new FileOutputStream(path+name);
    byte[] b=content.getBytes();
    outputStream.write(b);
    outputStream.close();

    Scanner scanner=new Scanner(new FileInputStream(path+name));
    scanner.useDelimiter("\n");
    StringBuffer stringBuffer=new StringBuffer();
    while (scanner.hasNext()){
        stringBuffer.append(scanner.next()+"<br/>");
    }
    scanner.close();
%>
<%=stringBuffer%>
</body>
</html>
